<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}


$page = !($_POST['pageNum'])?'1':intval($_POST['pageNum']);
$pagesize= !($_POST['numPerPage'])?'20':intval($_POST['numPerPage']);


if(empty($pagesize)){
    $pagesize=20;
}
$frmnum=($page-1)*$pagesize;
$orderField=trim($_POST["orderField"]);
$orderDirection=trim($_POST["orderDirection"]);
if(empty($orderField)){
    $orderField="id";
}
if(empty($orderDirection)){
    $orderDirection="desc";
}
if($orderField<>""){
    $order=" order by $orderField ".$orderDirection;
}else{
    $order=" order by id desc";
}
$q=trim($_POST['q']);

$sday=$_POST['sday']?$_POST['sday']:date("Y-m-d");
$eday=$_POST['eday']?$_POST['eday']:date("Y-m-d",time()+3600*30*24);

//$where=' status>-1';

/*
$shoplisttemp=$ezhand->get_shoptree("shopping3_shop");

$shoplist=array(""=>"选择所属店铺");
foreach($shoplisttemp as $val){
  $id=$val["id"];
  $shoplist[$id]=$val["sname"];  
    
}
$where='1=1';
$total=$ezhand->count("shopping3_cheftime",$where);
$row=$ezhand->select_all("shopping3_cheftime",'*',''.$where.' '.$order.' limit '.$frmnum.','.$pagesize);
foreach($row as $key=>$val){
    $row[$key]['shop_name']=$ezhand->get_snamebyshopid('shopping3_shop',"id=".$val['shop_id']."");
    $row[$key]['chef_name']=$ezhand->get_cnamebyshopid('shopping3_chef',"id=".$val['chef_id']."");
}
*/
$where="c.id=s.chefid ";
if(!empty($q)){
    
    $where.=" and c.name like '%".$q."%'";
}
if($sday<>""){
    $where.=" and s.sdate>='".$sday."' and s.sdate<='".$eday."'";
}
$total=$ezhand->count("shopping3_chef c,shopping3_schedule s",$where);
$row=$ezhand->select_all("shopping3_chef c,shopping3_schedule s",'c.*,s.sdate,s.orderid',''.$where.' '.$order.' limit '.$frmnum.','.$pagesize);


?>
